import {
	getToken
} from "./AuthUtils";

export const uploadFile = (url, filePath) => {
	const TOKEN = getToken();
	return new Promise((resolve, reject) => {
		let a = uni.uploadFile({
			url,
			filePath,
			name: 'file',
			header: {
				Authorization: TOKEN
			},
			success: (res) => {
				// 注意：需要进行JSON解析
				const result = JSON.parse(res.data);
				resolve(result)
			},
			fail: (err) => {
				reject(err)
			}
		});
	})
}